'use strict';
// 创建db对象
const db = uniCloud.database();
// 获取 `tt_interviews` 集合的引用
const interviewCollection = db.collection('tt_interviews');

exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)

	let {
		keyword
	} = event;
	if (keyword) {
		// 通过关键字对面试题表进行模糊查询
		const result = await interviewCollection.where({
				question: new RegExp(keyword, 'i') //模糊查询条件
			})
			.get()
		return result;
	} else {
		//返回数据给客户端
		return {
			msg: "缺少参数"
		}
	}


};